<%@page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8" %>
<!DOCTYPE HTML>
<html>
<head>
    <%@ include file="/admin/header.jsp" %>
    <%
        request.setAttribute("listUrl", com.sz.controller.frame.UserController.LIST_URL);
    %>
    <%
        request.setAttribute("modifyUrl", com.sz.controller.frame.UserController.MODIFY_URL);
    %>
    <%
        request.setAttribute("saveUrl", com.sz.controller.frame.UserController.SAVE_URL);
        request.setAttribute("reset", com.sz.controller.frame.UserController.RESET_URL);
    %>
    <%
        request.setAttribute("modifyUserRoleUrl", com.sz.controller.frame.UserController.MODIFY_USER_ROLE_URL);
    %>
    <%
        request.setAttribute("saveUserRoleUrl", com.sz.controller.frame.UserController.SAVE_USER_ROLE_URL);
    %>
    <script type="text/javascript">
        function change(uid, status, url) {
            var msg = "";
            if (status == 0) {
                msg = "确认恢复此用户吗";
            } else if (status == 1) {
                msg = "确认禁用此用户吗";
            } else {
                msg = "确认删除此用户吗";
            }
            layer.confirm(msg, function (index) {
                $.ajax({
                    async: false,
                    type: "post",
                    data: {
                        uid: uid,
                        status: status
                    },
                    url: "${ctx}/admin/user/changeStatus",
                    success: function (data) {
                        if (data.success) {
                            window.location = url;
                        } else {
                            layer.open({
                                title: '',
                                content: '更改用户状态失败，请稍后重试'
                            });
                        }
                    }
                });
            });
        }
    </script>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>用户管理
    <span class="c-gray en">&gt;</span>列表 <a
        class="btn btn-success radius r"
        style="line-height: 1.6em; margin-top: 3px"
        href="javascript:location.replace(location.href);" title="刷新"> <i
        class="Hui-iconfont">&#xe68f;</i>
</a>
</nav>
<div class="page-container">

    <form action="${ctx }${listUrl}" id="searchForm" method="post">
        <input id="curentPage" name="curentPage" type="hidden" value="1">
        <div class="text-c">
            <input id="username" name="username" value="${username }" type="text"
                   class="input-text" style="width: 250px" placeholder="输入用户名">
            <input id="name" name="name" value="${name }" type="text"
                   class="input-text" style="width: 250px" placeholder="输入姓名">
            <button type="submit" class="btn btn-success radius" id="" name="">
                <i class="Hui-iconfont">&#xe665;</i> 搜索
            </button>
        </div>
    </form>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
			<span class="l">
					<a href="javascript:;" class="btn btn-primary radius"
                       onclick="add('添加用户', '${ctx }${modifyUrl }')"> <i
                            class="Hui-iconfont">&#xe600;</i>添加
					</a>
			</span>
    </div>
    <div class="mt-20 dataTables_wrapper">
        <table
                class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="5%"><input type="checkbox"
                                      onclick="selectAll('listTable', 'ids', this);"></th>
                <th width="10%">用户名</th>
                <th width="10%">姓名</th>
                <th width="15%">座机</th>
                <th width="15%">手机</th>
                <th width="10%">状态</th>
                <th width="20%">操作</th>
            </tr>
            </thead>
            <tbody id="listTable">
            <c:forEach items="${list }" var="user" varStatus="s">
                <tr class="text-c">
                    <td><input type="checkbox" class="ids" value="${user.id}"></td>
                    <td>${user.username }</td>
                    <td>${user.name }</td>
                    <td>${user.telphone }</td>
                    <td>${user.cellphone }</td>
                    <td>${user.userStatusName }</td>
                    <td><c:if test="${user.userStatus != 3}">
                        <a href="javascript:;" class="btn btn-danger-outline radius size-MINI"
                           onclick="change('${user.id}',3,'${ctx }${listUrl }');">删除</a>
                        <a href="javascript:;" class="btn btn-success-outline radius size-MINI"
                           onclick="add('修改', '${ctx }${modifyUrl }?id=${user.id}');">修改</a>
                        <c:choose>
                            <c:when test="${user.userStatus==0}">
                                <a id="changeHref" href="javascript:;"
                                   class="btn btn-success-outline radius size-MINI"
                                   onclick="change('${user.id}',1,'${ctx }${listUrl }');">停用</a>
                            </c:when>
                            <c:when test="${user.userStatus==1}">
                                <a id="changeHref" href="javascript:;"
                                   class="btn btn-success-outline radius size-MINI"
                                   onclick="change('${user.id}',0,'${ctx }${listUrl }');">恢复</a>
                            </c:when>
                        </c:choose>
                        <a href="javascript:;"
                           class="btn btn-success-outline radius size-MINI"
                           onclick="add('重置密码', '${ctx }${reset }?id=${user.id}');">重置密码</a>
                    </c:if>
                        <c:if test="${user.userStatus == 3}">该用户已被删除</c:if></td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        ${page.showPages }
    </div>
</div>
<%@include file="/admin/footer.jsp" %>
</body>
</html>